test: replace PostgreSQL with CockroachDB in integration tests#896
Conversation
Replace PostgreSQL with CockroachDB in the integration test Docker Compose to match the production database environment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use cockroachdb/cockroach:latest in single-node insecure mode with in-memory storage. Add cockroachdb-init service to create the database and update the seed service to use cockroach sql CLI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Point DATABASE_URL at cockroachdb:26257 with root user (insecure mode). Enable DATABASE_MIGRATION_CONSTRAINT_FIX for CockroachDB compatibility. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace all PostgreSQL references with CockroachDB in the architecture diagram, components table, and troubleshooting section. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Up to standards ✅🟢 Issues
|
Greptile SummaryThis PR swaps the integration test database from
Confidence Score: 4/5Safe to merge — the changes are isolated to the test environment and do not touch any application code. All three CockroachDB containers use the unversioned
Important Files Changed
Sequence DiagramsequenceDiagram
participant DC as Docker Compose
participant CDB as cockroachdb (in-memory)
participant INIT as cockroachdb-init (one-shot)
participant API as api (Go)
participant SEED as seed (one-shot)
participant TR as Test Runner (go test)
DC->>CDB: start (start-single-node --insecure)
CDB-->>DC: "healthy (/health?ready=1)"
DC->>INIT: start (depends_on: cockroachdb healthy)
INIT->>CDB: CREATE DATABASE IF NOT EXISTS httpsms
INIT-->>DC: exit 0 (service_completed_successfully)
DC->>API: start (depends_on: cockroachdb-init completed)
API->>CDB: GORM auto-migrate (DDL)
API-->>DC: healthy (/health)
DC->>SEED: start (depends_on: api healthy)
SEED->>CDB: "cockroach sql --file=/seed.sql"
SEED-->>DC: exit 0
TR->>API: HTTP integration tests
API->>CDB: queries
CDB-->>API: results
API-->>TR: responses
Reviews (1): Last reviewed commit: "docs: update integration test README for..." | Re-trigger Greptile |
| cockroachdb: | ||
| image: cockroachdb/cockroach:latest | ||
| command: start-single-node --insecure --store=type=mem,size=256MiB |
There was a problem hiding this comment.
Using
cockroachdb/cockroach:latest for all three CockroachDB containers (cockroachdb, cockroachdb-init, seed) undermines the stated goal of matching production. If production is pinned to a specific CockroachDB version, latest may pull a newer release with different SQL semantics, migration behavior, or serialization changes — making the test environment diverge from production in exactly the way this PR aims to fix.
| cockroachdb: | |
| image: cockroachdb/cockroach:latest | |
| command: start-single-node --insecure --store=type=mem,size=256MiB | |
| cockroachdb: | |
| image: cockroachdb/cockroach:v24.3.4 # pin to the same version used in production | |
| command: start-single-node --insecure --store=type=mem,size=256MiB |
| # CockroachDB Integration Tests Implementation Plan | ||
|
|
||
| > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. | ||
|
|
||
| **Goal:** Replace PostgreSQL with CockroachDB in the integration test Docker Compose so the test environment matches production. |
There was a problem hiding this comment.
Agentic planning artifacts committed to the repository
These two files (docs/superpowers/plans/ and docs/superpowers/specs/) appear to be intermediate planning documents generated by an AI development workflow. Committing them adds permanent repository noise for content that has no value to future contributors — the implementation intent is better captured in the PR description and the resulting code. Consider whether these belong in .gitignore or a separate scratch branch rather than main.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The CockroachDB Docker image does not include curl. Use 'cockroach sql --execute=SELECT 1' for the healthcheck instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the integration test stack under tests/ to use CockroachDB instead of PostgreSQL, aligning the test environment’s database engine with production.
Changes:
- Swapped the
postgresservice for a single-nodecockroachdbservice, plus a one-shot init container to create thehttpsmsdatabase. - Updated test environment variables to point
DATABASE_URL*at CockroachDB and enabledDATABASE_MIGRATION_CONSTRAINT_FIX. - Updated integration test documentation and added accompanying design/plan docs.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/docker-compose.yml | Replaces PostgreSQL with CockroachDB, adds init step, updates API/seed dependencies accordingly. |
| tests/.env.test | Updates DB connection strings for CockroachDB and enables migration compatibility flag. |
| tests/README.md | Updates architecture diagram and text references from PostgreSQL to CockroachDB. |
| docs/superpowers/specs/2026-05-18-cockroachdb-integration-tests-design.md | Adds design spec documenting the rationale and approach. |
| docs/superpowers/plans/2026-05-18-cockroachdb-integration-tests.md | Adds implementation plan/checklist for the migration. |
| cockroachdb: | ||
| image: cockroachdb/cockroach:latest | ||
| command: start-single-node --insecure --store=type=mem,size=256MiB |
CockroachDB requires at least 640 MiB for in-memory storage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace PostgreSQL with CockroachDB in the integration test Docker Compose to match production.
Changes
Why
Production uses CockroachDB. This ensures tests exercise the same DB engine.
No application code changes needed (GORM postgres driver is wire-compatible).